package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    Page<DishVO> selectDishList(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where id = #{id}")
    DishVO selectById(Long id);

    void delete(List<Long> dishIdList);

    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> selectByCategory(Long categoryId);

    List<Integer> getStatus(List<Long> dishIdList);

    @Select("select dish.*, category.name categoryName from dish, category where dish.category_id = category.id and dish.category_id = #{categoryId} and dish.status = 1")
    List<DishVO> userSelectByCategory(Long categoryId);
}
